package com.sl.au.repository;

import java.util.List;

import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.transaction.annotation.Transactional;

import com.sl.au.entity.CustomerPayInfo;


/**
 *	获取附加开票信息List中的数据Repository
 *	显示主表中的主键等于CustomerPayInfo子表的外键的数据
 * @return
 */
@Transactional(readOnly = true)
public interface EXDECustomerPayInfoRepository extends JpaRepository<CustomerPayInfo, String> {
	/**查询CustomerPayInfo表中所有数据返回前端界面Table*/
	@Query("select c from CustomerPayInfo c where c.customer.id=?1 and (c.identification like %?2% or c.invoicePhone like %?2%  )")
	Page<CustomerPayInfo> findAllTrance(String CustomerId,String key,Pageable pageable);
	/**统计查询出数据的数量*/
	@Query("select count(*) from CustomerPayInfo c where c.customer.id=?1 and (c.identification like %?2% or c.invoicePhone like %?2%  )")
	long getCount(String CustomerId,String key);
	
	
	CustomerPayInfo findByCustomer_IdAndIsDefaultHost(String id, int i);
	CustomerPayInfo findByCustomer_IdAndIsDefaultPart(String id, int i);
	List<com.sl.au.entity.CustomerPayInfo> findByCustomer_Id(String customerId);
	@Query("select c from CustomerPayInfo c where c.customer.id=?1 order by c.updateTime desc")
	List<CustomerPayInfo> findByCustomer_IdByUpdateTimeDESC(String customerId);
	
}
